/*
 * Copyright [2019] No Copyright is Claimed
 * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
 * MD5 Message-Digest Algorithm (RFC 1321).
 *
 * Author:
 * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
 *
 * This software was written by Alexander Peslyak in 2001.  No copyright is
 * claimed, and the software is hereby placed in the public domain.
 * In case this attempt to disclaim copyright and place the software in the
 * public domain is deemed null and void, then the software is
 * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
 * general public under the following terms:
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted.
 *
 * There's ABSOLUTELY NO WARRANTY, express or implied.
 *
 * See md5.c for more information.
 */
// Homepage:
// http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5

#ifndef FILEADAPTER_MD5_H_
#define FILEADAPTER_MD5_H_

#include <cstddef>
#include <cstdint>

namespace MD5Test {

static const uint32_t KMd5ResultSize = 16;
static const uint32_t KMd5ResultStrSize = 33;
static const uint32_t KMd5CtxBufferSize = 64;
static const uint32_t KMd5CtxBlockSize = 16;


struct Md5Result {
  uint8_t md5_result_16[KMd5ResultSize];
};

struct Md5ResultStr {
  uint8_t result_str[KMd5ResultStrSize];
};

struct Md5Ctx {
  uint32_t md5_ctx_lo;
  uint32_t md5_ctx_hi;
  uint32_t md5_ctx_a;
  uint32_t md5_ctx_b;
  uint32_t md5_ctx_c;
  uint32_t md5_ctx_d;
  uint8_t md5_ctx_buffer[KMd5CtxBufferSize];
  uint32_t md5_ctx_block[KMd5CtxBlockSize];
};

extern void md5_init(Md5Ctx &out_ctx);
extern void md5_update(Md5Ctx &out_ctx, const void *origin_data, uint64_t in_size);
extern void md5_final(uint8_t *const out_result, Md5Ctx &out_ctx);
extern void md5_print(uint8_t *const out_buf, const uint8_t *const in_result, uint64_t in_len);

}  // namespace MD5Test

#endif  // FILEADAPTER_MD5_H_
